import request from '@/utils/request';

// 查询字典类型列表
export function listType(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/page',
		method: 'get',
		params: query,
	});
}

// 查询字典类型详细
export function getType(dictId: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/' + dictId,
		method: 'get',
	});
}

// 新增字典类型
export function addType(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict',
		method: 'post',
		data: data,
	});
}

// 修改字典类型
export function updateType(data: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict',
		method: 'put',
		data: data,
	});
}

// 删除字典类型
export function delType(dictId: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/dict/' + dictId,
		method: 'delete',
	});
}

// 清理参数缓存
export function clearCache() {
	return request({
		url: '/admin/dict/sync',
		method: 'put',
	});
}

// 导出字典类型
export function exportType(query: any): ApiPromise<ApiResponse> {
	return request({
		url: '/admin/system/dict/type/export',
		method: 'get',
		params: query,
	});
}

// 获取字典选择框列表
export function optionSelect() {
	return request({
		url: '/admin/system/dict/type/optionSelect',
		method: 'get',
	});
}
// 获取字典选择框列表
export function dictItemPage(params: any) {
	return request({
		url: '/admin/dict/item/page',
		method: 'get',
		params,
	});
}
